// kolokwium.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>

using namespace std;

void Odbij_lust(int *tab, int N)
{
	if ((N >= 4))
	{
		int *koniec = tab + N - 1;
		int odbij_l, odbij_p, *P = tab, *L=tab;
		if (N%2 == 0)
		{
			L += (N / 2- 1);
			P += N / 2;
		}
		else
		{
			L += (N / 2 - 1);
			P += (N / 2 + 1);
		}
		while(tab < L)
		{
			odbij_l = *tab;
			*tab = *L;
			*L = odbij_l;
			tab++;
			L--;
		}
		while(P < koniec)
		{
			odbij_p = *koniec;
			*koniec = *P;
			*P = odbij_p;
			P++;
			koniec--;
		}
	}
}

void Rysuj_tab(int *tab, int N)
{
	for (int i = 0; i < N; i++)
	{
		cout << *(tab+i) << " ";
	}
	cout << endl;
}

int main()
{
	const int DLUGOSC = 9;

	int tablica [DLUGOSC] = {0, 1, 2, 3, 4, 5, 6, 7, 8};

	Rysuj_tab(tablica, DLUGOSC);

	Odbij_lust(tablica, DLUGOSC);

	Rysuj_tab(tablica, DLUGOSC);

	system("PAUSE");
	return 0;
}

